﻿/*
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2009
' by DotNetNuke Corporation
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation 
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and 
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions 
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 
' DEALINGS IN THE SOFTWARE.
*/

using System;
using MbUnit.Framework;
using WatiN.Core;
using DotNetNuke.Tests.UI.WatiN.Common;
using Gallio.Framework;
using DotNetNuke.Tests.UI.WatiN.Utilities;
using System.Configuration;
using System.IO;
using WatiN.Core.DialogHandlers;
using DotNetNuke.Tests.UI.WatiN.Common.WatiNObjects;
using System.Text.RegularExpressions;

namespace DotNetNuke.Tests.UI.WatiN.SiteTests
{
    [TestFixture]
    public class PageTests : STBase
    {
        #region Test Setup and TearDown

        [SetUp]
        public void SetUp()
        {
            SetUpTest();
        }

        [TearDown]
        public void TearDown()
        {
            TearDownTest();
        }

        #endregion

        #region Tests

        [Test]
        public void Add_Page_From_Control_Panel_Ribbon_Bar()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            //Act
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(pageName);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.AreEqual(pageName, menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        public void Add_Page_From_Pages_Module()
        {
            //Arrange
            string capturePath = CapturePath + @"\PageTests\AddFromPagesModule\";
            if (!Directory.Exists(capturePath))
            {
                Directory.CreateDirectory(capturePath);
            }
            WatiNAssert watiNAssert = new WatiNAssert(ieInstance, capturePath);
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
           
            //Act
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            System.Threading.Thread.Sleep(2500);
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddPage(pageName);
            //pagesPage.AddNewPageImage.ClickNoWait();
            //PageSettingsPage newPage = new PageSettingsPage(homePage);
            //newPage.PageNameField.Value = pageName;
            //newPage.AddPageLink.ClickNoWait();
            //System.Threading.Thread.Sleep(3000);

            //Assert
            //Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            System.Threading.Thread.Sleep(1500);
            watiNAssert.AssertIsTrue(pagesPage.ModuleMessageSpan.InnerHtml.Contains("Page " + pageName + " Created"), "PagesPanel.jpg");
            watiNAssert.AssertIsTrue(pagesPage.PagesPanel.Span(Find.ByText(s => s.Contains(pageName))).Exists, "PagesPanel.jpg");
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.AreEqual(pageName, menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));          
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Hidden_Page_From_Pages_Module()
        {
            //Arrange
            string capturePath = CapturePath + @"\PageTests\AddFromPagesModule\";
            if (!Directory.Exists(capturePath))
            {
                Directory.CreateDirectory(capturePath);
            }
            WatiNAssert watiNAssert = new WatiNAssert(ieInstance, capturePath);
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";

            //Act
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddHiddenPage(pageName);

            //Assert
            System.Threading.Thread.Sleep(5500);
            watiNAssert.AssertIsTrue(pagesPage.PagesPanel.Span(Find.ByText(s => s.Contains(pageName))).Exists, "PagesPanel.jpg");
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.AreEqual(pageName, menu.BreadCrumbSpan.Text);
            watiNAssert.AssertIsFalse(menu.MainMenu.InnerHtml.Contains(pageName), "HiddenPageInMenu.jpg");   
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Hidden_Page_From_Control_Panel_Ribbon_Bar()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            //Act
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddHiddenPage(pageName);
           
            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.AreEqual(pageName, menu.BreadCrumbSpan.Text);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Child_Page_From_Pages_Module()
        {
            //Arrange
            string capturePath = CapturePath + @"\PageTests\AddFromPagesModule\";
            if (!Directory.Exists(capturePath))
            {
                Directory.CreateDirectory(capturePath);
            }
            WatiNAssert watiNAssert = new WatiNAssert(ieInstance, capturePath);
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String parentName = "Parent Page";
            String pageName = "Child Page";

            //Add a parent page
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddPage(parentName);
            System.Threading.Thread.Sleep(1500);
            watiNAssert.AssertIsTrue(pagesPage.ModuleMessageSpan.InnerHtml.Contains("Page " + parentName + " Created"), "ParentMissing.jpg");

            //Act 
            pagesPage.AddChildPage(pageName, parentName);

            //Assert
            System.Threading.Thread.Sleep(1500);
            watiNAssert.AssertIsTrue(pagesPage.ModuleMessageSpan.InnerHtml.Contains("Page " + pageName + " Created"), "ChildMissing.jpg");
            watiNAssert.AssertIsTrue(pagesPage.PagesPanel.Span(Find.ByText(s => s.Contains(pageName))).Exists, "PagesPanel.jpg");
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/ParentPage/ChildPage.aspx");
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(pageName));
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(parentName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Child_Page_From_Control_Panel_Ribbon_Bar()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String parentName = "Parent Page";
            String pageName = "Child Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonbar = false;
            //Add parent page
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonbar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(parentName);

            //Act 
            if (usesRibbonbar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            newPage.AddChildPage(pageName, parentName);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(pageName));
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(parentName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Child_Page_From_Pages_Module")]
        public void Add_GrandChild_Page_From_Pages_Module()
        {
            //Arrange
            string capturePath = CapturePath + @"\PageTests\AddFromPagesModule\";
            if (!Directory.Exists(capturePath))
            {
                Directory.CreateDirectory(capturePath);
            }
            WatiNAssert watiNAssert = new WatiNAssert(ieInstance, capturePath);
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String parentName = "Parent Page";
            String childName = "Child Page";
            String grandchildName = "GrandChild Page";

            //Add a parent page
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddPage(parentName);
            System.Threading.Thread.Sleep(1500);
            watiNAssert.AssertIsTrue(pagesPage.ModuleMessageSpan.InnerHtml.Contains("Page " + parentName + " Created"), "ParentMissing.jpg");
            pagesPage.AddChildPage(childName, parentName);
            System.Threading.Thread.Sleep(1500);
            watiNAssert.AssertIsTrue(pagesPage.ModuleMessageSpan.InnerHtml.Contains("Page " + childName + " Created"), "ChildMissing.jpg");
           
            //Act 
            pagesPage.AddChildPage(grandchildName, childName);
           
            //Assert
            System.Threading.Thread.Sleep(1500);
            watiNAssert.AssertIsTrue(pagesPage.ModuleMessageSpan.InnerHtml.Contains("Page " + grandchildName + " Created"), "GrandChildMissing.jpg");
            watiNAssert.AssertIsTrue(pagesPage.PagesPanel.Span(Find.ByText(s => s.Contains(grandchildName))).Exists, "PagesPanel.jpg");
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/ParentPage/ChildPage/GrandchildPage.aspx");
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(grandchildName));
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(childName));
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(parentName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(grandchildName));
        }

        [Test]
        [DependsOn("Add_Child_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_GrandChild_Page_Control_Panel_Ribbon_Bar()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String parentName = "Parent Page";
            String childName = "Child Page";
            String grandchildName = "GrandChild Page";

            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonbar = false;
            //Add parent page
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonbar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(parentName);

            if (usesRibbonbar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            newPage.AddChildPage(childName, parentName);

            //Act 
            if (usesRibbonbar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            newPage.AddChildPage(grandchildName, "..." + childName);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(grandchildName));
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(childName));
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(parentName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(grandchildName));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Page_From_Pages_Module_View_Permissions_Restricted()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";

            //Add two users
            ieInstance.GoTo(SiteURL + "/Admin/UserAccounts.aspx");
            UserPage userPage = new UserPage(homePage);
            userPage.AddUser(TestUsers.User1.UserName, TestUsers.User1.Password, TestUsers.User1.FirstName, TestUsers.User1.LastName, TestUsers.User1.EmailAddress, TestUsers.User1.DisplayName);
            System.Threading.Thread.Sleep(2000);
            userPage.AddUser(TestUsers.User2.UserName, TestUsers.User2.Password, TestUsers.User2.FirstName, TestUsers.User2.LastName, TestUsers.User2.EmailAddress, TestUsers.User2.DisplayName);
            System.Threading.Thread.Sleep(2000);

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddPageGiveUserViewPermission(pageName, TestUsers.User1.UserName, TestUsers.User1.DisplayName);

            //Assert 
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            loginPage.LogoffUser();
            loginPage.LoginUser(TestUsers.User1.UserName, TestUsers.User1.Password);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsFalse(homePage.ModuleMessageSpan.Exists);
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Enter Title"));
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            loginPage.LogoffUser();
            loginPage.LoginUser(TestUsers.User2.UserName, TestUsers.User2.Password);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsTrue(homePage.ModuleMessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(homePage.ModuleTitleSpan.InnerHtml.Contains("Access Denied"));
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbLink.Text.Equals(pageName));

        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_View_Permissions_Restricted()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";

            //Add two users
            ieInstance.GoTo(SiteURL + "/Admin/UserAccounts.aspx");
            UserPage userPage = new UserPage(homePage);
            userPage.AddUser(TestUsers.User1.UserName, TestUsers.User1.Password, TestUsers.User1.FirstName, TestUsers.User1.LastName, TestUsers.User1.EmailAddress, TestUsers.User1.DisplayName);
            System.Threading.Thread.Sleep(2000);
            userPage.AddUser(TestUsers.User2.UserName, TestUsers.User2.Password, TestUsers.User2.FirstName, TestUsers.User2.LastName, TestUsers.User2.EmailAddress, TestUsers.User2.DisplayName);
            System.Threading.Thread.Sleep(2000);

            //Act 
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            //Add parent page
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageGiveUserViewPermission(pageName, TestUsers.User1.UserName);

            //Assert 
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Equals(pageName));
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            loginPage.LogoffUser();
            System.Threading.Thread.Sleep(1500);
            loginPage.LoginUser(TestUsers.User1.UserName, TestUsers.User1.Password);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            if (homePage.MessageSpan.Exists)
            {
                Assert.IsFalse(homePage.MessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));
            }
            else
            {
                Assert.IsFalse(homePage.MessageSpan.Exists);
            }
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Enter Title"));
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            loginPage.LogoffUser();
            System.Threading.Thread.Sleep(1500);
            loginPage.LoginUser(TestUsers.User2.UserName, TestUsers.User2.Password);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsTrue(homePage.ModuleMessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(homePage.ModuleTitleSpan.InnerHtml.Contains("Access Denied"));
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Equals(pageName));

        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Linked_To_Another_Page()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String linkPageName = "Link Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            //Add a page to link to 
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(linkPageName);
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            String pageName = "test page";

            //Act 
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            newPage.PageNameField.Value = pageName;
            newPage.AdvancedSettingsTabLink.Click();
            newPage.LinkToPageRadioButton.Checked = true;
            System.Threading.Thread.Sleep(1000);
            newPage.LinkedPageSelectList.Select(linkPageName);
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Assert 
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(linkPageName));
            ieInstance.Span(Find.ByText(pageName)).Click();
            Assert.AreEqual(linkPageName, menu.BreadCrumbSpan.Text);
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Page_From_Pages_Module_Linked_To_Another_Page()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String linkPageName = "Link Page";

            //Add a page to link to 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddPage(linkPageName);
            String pageName = "test page";

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddNewPageImage.Click();
            newPage.PageNameField.Value = pageName;
            newPage.AdvancedSettingsExpandButton.Click();
            newPage.LinkToPageRadioButton.ClickNoWait();
            System.Threading.Thread.Sleep(1500);
            newPage.LinkedPageSelectList.Select(linkPageName);
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert 
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            Assert.IsTrue(pagesPage.PagesSelectList.Option(linkPageName).Exists);
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(linkPageName));
            ieInstance.Span(Find.ByText(pageName)).Click();
            Assert.AreEqual(linkPageName, menu.BreadCrumbSpan.Text);
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_Linked_To_URL()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            
            //Act 
            string pageName = "Test Page";
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.AdvancedSettingsTabLink.Click();
            newPage.LinkURLTypeRadioButton.Checked = true;
            System.Threading.Thread.Sleep(3000);
            newPage.UrlTextField.Value = "http://www.facebook.com";
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            Span testSpan = ieInstance.Span(Find.ByText(pageName));
            testSpan.Click();
            Assert.IsTrue(ieInstance.Url.Contains("www.facebook.com"));
            Assert.IsTrue(ieInstance.Title.Contains("Facebook"));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Page_From_Pages_Module_Linked_To_URL()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            string pageName = "Test Page";
           
            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddNewPageImage.Click();
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.AdvancedSettingsExpandButton.Click();
            newPage.LinkURLTypeRadioButton.Checked = true;
            System.Threading.Thread.Sleep(3000);
            newPage.UrlTextField.Value = "http://www.facebook.com";
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Assert
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            Span testSpan = ieInstance.Span(Find.ByText(pageName));
            testSpan.Click();
            Assert.IsTrue(ieInstance.Url.Contains("www.facebook.com"));
            Assert.IsTrue(ieInstance.Title.Contains("Facebook"));
        }
               
        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_Start_Date_Future()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            DateTime date = DateTime.Now;
            int year = date.Year;
            year = year + 3;
            string dateString = date.Month + "/" + date.Day + "/" + year;

            //Act 
            string pageName = "Test Page";
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.AllUsersViewPermissionCheckbox.ClickNoWait();
            newPage.AdvancedSettingsTabLink.ClickNoWait();
            newPage.StartDateTextField.Value = dateString;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1500);
            loginPage.LogoffUser();

            //Assert
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            System.Threading.Thread.Sleep(1500);
             Assert.IsTrue(homePage.ModuleMessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));
            
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Page_From_Pages_Module_Start_Date_Future()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            DateTime date = DateTime.Now;
            int year = date.Year;
            year = year + 3;
            string dateString = date.Month + "/" + date.Day + "/" + year;
            string pageName = "Test Page";

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddNewPageImage.Click();
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.AllUsersViewPermissionCheckbox.Click();
            newPage.AdvancedSettingsExpandButton.Click();
            newPage.StartDateTextField.Value = dateString;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Assert
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            loginPage.LogoffUser();
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsTrue(homePage.ModuleMessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));
            loginPage.LogoffUser();
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_Start_Date_Past()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            DateTime date = DateTime.Now;
            int year = date.Year;
            year = year - 3;
            string dateString = date.Month + "/" + date.Day + "/" + year;

            //Act 
            string pageName = "Test Page";
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.ClickViewPermissionForRole("All Users");
            newPage.AdvancedSettingsExpandButton.Click();
            newPage.StartDateTextField.Value = dateString;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            if (homePage.MessageSpan.Exists)
            {
                Assert.IsFalse(homePage.MessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));
            }
            else
            {
                Assert.IsFalse(homePage.MessageSpan.Exists);
            }
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(pageName));
            loginPage.LogoffUser();
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Page_From_Pages_Module_Start_Date_Past()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            DateTime date = DateTime.Now;
            int year = date.Year;
            year = year - 3;
            string dateString = date.Month + "/" + date.Day + "/" + year;
            string pageName = "Test Page";

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddNewPageImage.Click();
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.ClickViewPermissionForRole("All Users");
            newPage.AdvancedSettingsExpandButton.Click();
            newPage.StartDateTextField.Value = dateString;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Assert
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");            
            if (homePage.MessageSpan.Exists)
            {
                Assert.IsFalse(homePage.MessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));
            }
            else
            {
                Assert.IsFalse(homePage.MessageSpan.Exists);
            }
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(pageName));
            loginPage.LogoffUser();
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_End_Date_Past()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            DateTime date = DateTime.Now;
            int year = date.Year;
            year = year - 3;
            string dateString = date.Month + "/" + date.Day + "/" + year;

            //Act 
            string pageName = "Test Page";
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.ClickViewPermissionForRole("All Users");
            newPage.AdvancedSettingsTabLink.ClickNoWait();
            newPage.EndDateTextField.Value = dateString;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);
            loginPage.LogoffUser();

            //Assert
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            System.Threading.Thread.Sleep(5500);
            Assert.IsTrue(homePage.ModuleMessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));
            
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Page_From_Pages_Module_End_Date_Past()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            DateTime date = DateTime.Now;
            int year = date.Year;
            year = year - 3;
            string dateString = date.Month + "/" + date.Day + "/" + year;
            string pageName = "Test Page";

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddNewPageImage.Click();
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.ClickViewPermissionForRole("All Users");
            newPage.AdvancedSettingsExpandButton.Click();
            newPage.EndDateTextField.Value = dateString;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Assert
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            loginPage.LogoffUser();
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsTrue(homePage.ModuleMessageSpan.InnerHtml.Contains("You do not have access to view this tab within the portal."));

            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_End_Date_Future()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            DateTime date = DateTime.Now;
            int year = date.Year;
            year = year + 3;
            string dateString = date.Month + "/" + date.Day + "/" + year;

            //Act 
            string pageName = "Test Page";
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.ClickViewPermissionForRole("All Users");
            newPage.AdvancedSettingsTabLink.ClickNoWait();
            newPage.EndDateTextField.Value = dateString;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1000);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsFalse(homePage.ModuleMessageSpan.Exists);
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(pageName));
            loginPage.LogoffUser();
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Page_From_Pages_Module_End_Date_Future()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            DateTime date = DateTime.Now;
            int year = date.Year;
            year = year + 3;
            string dateString = date.Month + "/" + date.Day + "/" + year;
            string pageName = "Test Page";

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddNewPageImage.Click();
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.PageNameField.Value = pageName;
            newPage.ClickViewPermissionForRole("All Users");
            newPage.AdvancedSettingsExpandButton.Click();
            newPage.EndDateTextField.Value = dateString;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(pageName));
            Assert.IsFalse(homePage.ModuleMessageSpan.Exists);
            loginPage.LogoffUser();
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Add_Page_From_Pages_Module_No_Template_Selected()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddNewPageImage.ClickNoWait();
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(pageName, "None Specified");

            //Assert
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
            SiteMenu menu = new SiteMenu(homePage);
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.AreEqual(pageName, menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsFalse(homePage.ContentPane.Div(Find.ByClass("head_title")).Exists);
        }

         [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_No_Template_Selected()
        {
        
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            //Act
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(pageName, "None Specified");

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.AreEqual(pageName, menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsFalse(homePage.ContentPane.Div(Find.ByClass("head_title")).Exists);
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_New_Copy()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            String copyName = "Copy Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;
            //Add a page to the site
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(pageName, "None Specified");
           
            //Add a module to the page 
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            if (!usesRibbonBar)
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
                }
            }
            else
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);

                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);

                }
            }
            

            //Act 
            System.Threading.Thread.Sleep(1500);
            if (usesRibbonBar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.ClickNoWait();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.ClickNoWait();
            }
            newPage.PageNameField.Value = copyName;
            newPage.CopyPageSelectList.Select(pageName);
            newPage.NewCopyRadioButton.Checked = true;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.AreEqual(copyName, menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(copyName));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
            Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
        }

        //[Test]
        //[DependsOn("Add_Page_From_Pages_Module")]
        //public void Add_Page_From_Pages_Module_New_Copy()
        //{
        //    //Arrange
        //    WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
        //    LoginPage loginPage = new LoginPage(homePage);
        //    loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
        //    String pageName = "Test Page";
        //    String copyName = "Copy Page";
        //    ControlPanel controlPanel = null;
        //    RibbonBar ribbonBar = null;
        //    bool usesRibbonBar = !homePage.SiteIsUsingIconBar();
            
        //    //Add a page to the site and module to the page
        //    PageSettingsPage pageSettings = new PageSettingsPage(homePage);

        //    if(usesRibbonBar)
        //    {
        //        ribbonBar = new RibbonBar(homePage);
        //        ribbonBar.AddPageLink.Click();
                
        //        pageSettings.AddPageSelectTemplate(pageName, "None Specified");
        //        System.Threading.Thread.Sleep(1500);

        //        if (VersionType.CompareTo("Community") == 0)
        //        {
        //            ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);

        //        }
        //        else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
        //        {
        //            ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);

        //        }
        //    }
        //    else
        //    {
        //        controlPanel = new ControlPanel(homePage);
        //        controlPanel.AddPageLink.Click();
        //        pageSettings.AddPageSelectTemplate(pageName, "None Specified");
        //        System.Threading.Thread.Sleep(1500);

        //        if (VersionType.CompareTo("Community") == 0)
        //        {
        //            controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
        //        }
        //        else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
        //        {
        //            controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
        //        }

        //    }
       
        //    //Act 
        //    ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
        //    PageSettingsPage newPage = new PageSettingsPage(homePage);
        //    pagesPage.AddNewPageImage.Click();
        //    newPage.PageNameField.Value = copyName;
        //    newPage.CopyPageSelectList.Select(pageName);
        //    newPage.NewCopyRadioButton.ClickNoWait();
        //    newPage.AddPageLink.Click();
        //    System.Threading.Thread.Sleep(3000);

        //    //Assert
        //    Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
        //    SiteMenu menu = new SiteMenu(homePage);
        //    ieInstance.GoTo(SiteURL + "/copypage.aspx");
        //    Assert.AreEqual(copyName, menu.BreadCrumbSpan.Text);
        //    Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(copyName));
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
        //    Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
        //}

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_Copy()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            String copyName = "Copy Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;
            //Add a page to the site
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(pageName, "None Specified");
           
            //Add a module to the page 
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            if (!usesRibbonBar)
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
                }
            }
            else
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
                }
            }

            //Act 
            System.Threading.Thread.Sleep(2500);
            if (usesRibbonBar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            newPage.PageNameField.Value = copyName;
            newPage.CopyPageSelectList.Select(pageName);
            newPage.CopyPageSelectList.Refresh();
            newPage.CopyRadioButton.Checked = true;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.AreEqual(copyName, menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(copyName));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
            //Change the text on the copied module
            ModulePage modulePage = new ModulePage(homePage);
            modulePage.AddContentToModule("Something new", 0);
           
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
            Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Something new"));
            //Change the text on the original module
            modulePage.AddContentToModule("different text", 0);
           

            ieInstance.GoTo(SiteURL + "/copypage.aspx");
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Something new"));
            Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
            Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("different text"));
        }

        //[Test]
        //[DependsOn("Add_Page_From_Pages_Module")]
        //public void Add_Page_From_Pages_Module_Copy()
        //{
        //    //Arrange
        //    WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
        //    LoginPage loginPage = new LoginPage(homePage);
        //    loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
        //    String pageName = "Test Page";
        //    String copyName = "Copy Page";
        //    ControlPanel controlPanel = null;
        //    RibbonBar ribbonBar = null;

        //    //Add a page to the site
        //    ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
        //    AdminPagesPage pagesPage = new AdminPagesPage(homePage);
        //    pagesPage.AddPageSelectTemplate(pageName, "None Specified");
           
        //    //Add a module to the page 
        //    ieInstance.GoTo(SiteURL + "/testpage.aspx");
        //    if (homePage.ControlPanelElement.Id.CompareTo(homePage.RibbonBarID) != 0)
        //    {
        //        controlPanel = new ControlPanel(homePage);
        //        if (VersionType.CompareTo("Community") == 0)
        //        {
        //            controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
        //        }
        //        else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
        //        {
        //            controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
        //        }
        //    }
        //    else
        //    {
        //        ribbonBar = new RibbonBar(homePage);
        //        if (VersionType.CompareTo("Community") == 0)
        //        {
        //            ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);

        //        }
        //        else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
        //        {
        //            ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);

        //        }
        //    }

        //    //Act 
        //    ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
        //    pagesPage.AddNewPageImage.Click();
        //    PageSettingsPage newPage = new PageSettingsPage(homePage);
        //    newPage.PageNameField.Value = copyName;
        //    newPage.CopyPageSelectList.Select(pageName);
        //    newPage.CopyRadioButton.ClickNoWait();
        //    newPage.AddPageLink.ClickNoWait();
        //    System.Threading.Thread.Sleep(3000);

        //    //Assert
        //    ieInstance.GoTo(SiteURL + "/copypage.aspx");
        //    SiteMenu menu = new SiteMenu(homePage);
        //    Assert.AreEqual(copyName, menu.BreadCrumbSpan.Text);
        //    Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(copyName));
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
        //    //Change the text on the copied module
        //    ModulePage modulePage = new ModulePage(homePage);
        //    modulePage.AddContentToModule("Something new", 0);
           
        //    ieInstance.GoTo(SiteURL + "/testpage.aspx");
        //    System.Threading.Thread.Sleep(1500);
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
        //    Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Something new"));
        //    //Change the text on the original module
        //    modulePage.AddContentToModule("different text", 0);
            
        //    ieInstance.GoTo(SiteURL + "/copypage.aspx");
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Something new"));
        //    Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
        //    Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("different text"));
        //}

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Page_From_Control_Panel_Ribbon_Bar_Referenced_Copy()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            String copyName = "Copy Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;
            //Add a page to the site
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(pageName, "None Specified");
          
            //Add a module to the page 
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            if (!usesRibbonBar)
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
                }
            }
            else
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
                }
            }

            //Act 
            System.Threading.Thread.Sleep(1500);
            if (usesRibbonBar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            newPage.PageNameField.Value = copyName;
            newPage.CopyPageSelectList.Select(pageName);
            newPage.ReferencedCopyRadioButton.Checked = true;
            newPage.AddPageLink.Click();
            System.Threading.Thread.Sleep(3000);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.AreEqual(copyName, menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(copyName));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
            //Change the text on the copied module
            ModulePage modulePage = new ModulePage(homePage);
            modulePage.AddContentToModule("Something new", 0);
            System.Threading.Thread.Sleep(1500);
            
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
            Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Something new"));
            //Change the text on the original module
            modulePage.AddContentToModule("different text", 0);

            ieInstance.GoTo(SiteURL + "/copypage.aspx");
            Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Something new"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("different text"));
        }

        //[Test]
        //[DependsOn("Add_Page_From_Pages_Module")]
        //public void Add_Page_From_Pages_Module_Referenced_Copy()
        //{
        //    //Arrange
        //    WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
        //    LoginPage loginPage = new LoginPage(homePage);
        //    loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
        //    String pageName = "Test Page";
        //    String copyName = "Copy Page";
        //    ControlPanel controlPanel = null;
        //    RibbonBar ribbonBar = null;

        //    //Add a page to the site
        //    ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
        //    AdminPagesPage pagesPage = new AdminPagesPage(homePage);
        //    pagesPage.AddPageSelectTemplate(pageName, "None Specified");
            
        //    //Add a module to the page 
        //    ieInstance.GoTo(SiteURL + "/testpage.aspx");
        //    if (homePage.ControlPanelElement.Id.CompareTo(homePage.RibbonBarID) != 0)
        //    {
        //        controlPanel = new ControlPanel(homePage);
        //        if (VersionType.CompareTo("Community") == 0)
        //        {
        //            controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
        //        }
        //        else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
        //        {
        //            controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
        //        }
        //    }
        //    else
        //    {
        //        ribbonBar = new RibbonBar(homePage);
        //        if (VersionType.CompareTo("Community") == 0)
        //        {
        //            ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
        //        }
        //        else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
        //        {
        //            ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);

        //        }
        //    }
        //    ModulePage modulePage = new ModulePage(homePage);
            
        //    //Act 
        //    ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
        //    pagesPage.AddNewPageImage.Click();
        //    PageSettingsPage newPage = new PageSettingsPage(homePage);
        //    newPage.PageNameField.Value = copyName;
        //    newPage.CopyPageSelectList.Select(pageName);
        //    newPage.ReferencedCopyRadioButton.Checked = true;
        //    newPage.AddPageLink.ClickNoWait();
        //    System.Threading.Thread.Sleep(3000);

        //    //Assert
        //    ieInstance.GoTo(SiteURL + "/copypage.aspx");
        //    SiteMenu menu = new SiteMenu(homePage);
        //    Assert.AreEqual(copyName, menu.BreadCrumbSpan.Text);
        //    Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(copyName));
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
        //    //Change the text on the copied module
        //    modulePage.AddContentToModule("Something new", 0);
            
        //    ieInstance.GoTo(SiteURL + "/testpage.aspx");
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
        //    Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Something new"));
        //    //Change the text on the original module
        //    modulePage.AddContentToModule("different text", 0);
            
        //    ieInstance.GoTo(SiteURL + "/copypage.aspx");
        //    Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Something new"));
        //    Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("different text"));
        //}

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Modify_Page_From_Control_Panel_Parent_To_Child()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            Boolean usesRibbonBar = false;
            SiteMenu menu = new SiteMenu(homePage);

            //Two pages must first be added
            string pageName = "Test Page 1";
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(pageName);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            string pageName2 = "Test Page 2";
            if (usesRibbonBar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            newPage.AddPage(pageName2);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName2));
            
            //Act 
            ieInstance.GoTo(SiteURL + "/testpage2.aspx");
            if (usesRibbonBar)
            {
                ribbonBar.EditCurrentPageLink.Click();
            }
            else
            {
                controlPanel.PageSettingsLink.Click();
            }

            newPage.ParentPageSelection.Select(pageName);
            newPage.UpdatePageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert 
            Assert.AreEqual((pageName + pageName2), menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName2));
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            System.Threading.Thread.Sleep(7000);
            Assert.IsTrue(pagesPage.PagesSelectList.Option("..." + pageName2).Exists);
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_Page_From_Pages_Module_Parent_To_Child()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page 1";
            String pageName2 = "Test Page 2";

            //Two pages must first be added
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            pagesPage.AddPage(pageName);
            pagesPage.AddPage(pageName2);
            

            //Act 
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.PagesSelectList.Select(pageName2);
            pagesPage.EditSelectedPageImage.ClickNoWait();
            newPage.ParentPageSelection.Select(pageName);
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(2000);

            //Assert 
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(pagesPage.PagesSelectList.Option("..." + pageName2).Exists);
            ieInstance.GoTo(SiteURL + "/testpage1/testpage2.aspx");
            Assert.AreEqual((pageName + " > " + pageName2), menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName2));
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Modify_Page_From_Control_Panel_Child_To_Parent()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            Boolean usesRibbonBar = false;
            SiteMenu menu = new SiteMenu(homePage);

            //Two pages must first be added
            string pageName = "Test Page 1";
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(pageName);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            string pageName2 = "Test Page 2";
            if (usesRibbonBar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            newPage.AddChildPage(pageName2, pageName);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName2));

            //Act 
            ieInstance.GoTo(SiteURL + "/testpage1/testpage2.aspx");
            System.Threading.Thread.Sleep(2000);

            if (usesRibbonBar)
            {
                ribbonBar.EditCurrentPageLink.Click();
            }
            else
            {
                controlPanel.PageSettingsLink.Click();
            }

            newPage.ParentPageSelection.Select("<None Specified>");
            newPage.UpdatePageLink.ClickNoWait();
            System.Threading.Thread.Sleep(2000);

            //Assert 
            Assert.IsFalse(menu.BreadCrumbSpan.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(pageName2));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName2));
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            System.Threading.Thread.Sleep(7000);
            int pos = pagesPage.PageSpans.Count-1;
            Assert.IsTrue(pagesPage.PageSpans[pos].InnerHtml.Contains(pageName2), pagesPage.PageSpans[pos].InnerHtml);
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_Page_From_Pages_Module_Child_To_Parent()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page 1";
            String pageName2 = "Test Page 2";

            //Two pages must first be added
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName);

            pagesPage.AddChildPage(pageName2, pageName);
            
            //Act 
            pagesPage.PagesSelectList.Select("..." + pageName2);
            pagesPage.EditSelectedPageImage.ClickNoWait();
            newPage.ParentPageSelection.Select("<None Specified>");
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(2000);

            //Assert 
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName2).Exists);
            ieInstance.GoTo(SiteURL + "/testpage2.aspx");
            Assert.IsTrue(menu.BreadCrumbSpan.InnerHtml.Contains(pageName2));
            Assert.IsFalse(menu.BreadCrumbSpan.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName2));
        }


        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Modify_Page_From_Control_Panel_Change_Skin()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            String pageName = "Test Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;

            //Add a skin
            ieInstance.GoTo(SiteURL + "/tabid/36/portalid/0/Default.aspx");
            ExtensionsPage extensionsPage = new ExtensionsPage(homePage);
            extensionsPage.InstallExtension(SkinPath);
            ieInstance.GoTo(SiteURL + "/Home.aspx");

            //Add a page
            System.Threading.Thread.Sleep(1500);
            loginPage.LogoffUser();
            System.Threading.Thread.Sleep(1500);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(pageName);

            //Act 
            if (usesRibbonBar)
            {
                ribbonBar.EditCurrentPageLink.Click();
            }
            else
            {
                controlPanel.PageSettingsLink.Click();
            }
            newPage.AdvancedSettingsTabLink.ClickNoWait();
            newPage.PageSkinSelect.Select(SkinUsed);
            System.Threading.Thread.Sleep(1000);
            newPage.UpdatePageLink.ClickNoWait();
            System.Threading.Thread.Sleep(2500);

            //Assert 
            ElementContainer<Element> header = (ElementContainer<Element>)ieInstance.Element(Find.ById("Head"));
            Regex stylesheetRegex = new Regex(@".*_Skins_" + SkinName + "_", RegexOptions.IgnoreCase);
            ieInstance.Refresh();
            Element stylesheet = header.Elements.Filter(Find.ById(stylesheetRegex))[0];
            Assert.IsTrue(stylesheet.Exists);
            Assert.IsTrue(stylesheet.GetAttributeValue("rel").CompareTo("stylesheet") == 0);

            ieInstance.GoTo(SiteURL + "/Home.aspx");
            header = (ElementContainer<Element>)ieInstance.Element(Find.ById("Head"));
            Regex skinRegex = new Regex(@".*_Skins_DarkKnight.*_", RegexOptions.IgnoreCase);
            stylesheet = header.Elements.Filter(Find.ById(skinRegex))[0];
            Assert.IsTrue(stylesheet.Exists);
            Assert.IsTrue(stylesheet.GetAttributeValue("rel").CompareTo("stylesheet") == 0);

        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_Page_From_Pages_Module_Change_Skin()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Host.UserName, TestUsers.Host.Password);
            String pageName = "Test Page";
           
            //Add a skin
            ieInstance.GoTo(SiteURL + "/tabid/36/portalid/0/Default.aspx");
            ExtensionsPage extensionsPage = new ExtensionsPage(homePage);
            extensionsPage.InstallExtension(SkinPath);
            ieInstance.GoTo(SiteURL + "/Home.aspx");

            //Add a page
            loginPage.LogoffUser();
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName);

            //Act 
            pagesPage.PagesSelectList.Select(pageName);
            pagesPage.EditSelectedPageImage.Click();
            newPage.AdvancedSettingsExpandButton.Click();
            newPage.PageSkinSelect.Select(SkinUsed);
            System.Threading.Thread.Sleep(1000);
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert 
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            ElementContainer<Element> header = (ElementContainer<Element>)ieInstance.Element(Find.ById("Head"));
            Regex stylesheetRegex = new Regex(@".*_Skins_" + SkinName + "_", RegexOptions.IgnoreCase);
            Element stylesheet = header.Elements.Filter(Find.ById(stylesheetRegex))[0];
            Assert.IsTrue(stylesheet.Exists);
            Assert.IsTrue(stylesheet.GetAttributeValue("rel").CompareTo("stylesheet") == 0);

            ieInstance.GoTo(SiteURL + "/Home.aspx");
            header = (ElementContainer<Element>)ieInstance.Element(Find.ById("Head"));
            String minimalExtropyString;
            if (VersionType.CompareTo("Community") == 0)
            {
                minimalExtropyString = "Skins_MinimalExtropy_";
            }
            else
            {
                minimalExtropyString = "Skins_MinimalExtropyPro_";
            }

            stylesheet = header.Elements.Filter(Find.ById(s => s.Contains(minimalExtropyString)))[0];
            Assert.IsTrue(stylesheet.Exists);
            Assert.IsTrue(stylesheet.GetAttributeValue("rel").CompareTo("stylesheet") == 0);

        }
        
        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Delete_Page_From_Control_Panel_RibbonBar()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            Link DeletePageLink = null;
            Boolean usesRibbonBar = false;
            //A page must first be added
            string pageName = "Test Page";
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(pageName);
            ConfirmDialogHandler dialog = new ConfirmDialogHandler();
            if (usesRibbonBar)
            {
                //ribbonBar.CurrentPageTabLink.Click();
                DeletePageLink = ribbonBar.DeletePageLink;
            }
            else
            {
                DeletePageLink = controlPanel.DeletePageLink;
            }

            //Act 
            DeletePageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);
            if (usesRibbonBar)
            {
                ribbonBar.PopUpConfirmation.ClickNoWait();
            }
            else
            {
                using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
                {
                    DeletePageLink.ClickNoWait();
                    dialog.WaitUntilExists();
                    dialog.OKButton.Click();
                }
                ieInstance.WaitForComplete();
            }
            System.Threading.Thread.Sleep(3000);
            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
            ieInstance.GoTo(SiteURL + "/Admin/RecycleBin.aspx");
            RecycleBinPage recycleBin = new RecycleBinPage(homePage);
            Assert.IsTrue(recycleBin.PagesRecycleBin.InnerHtml.Contains(pageName));

        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Delete_Page_From_Pages_Module()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Delete Page";

            //Add a page to delete
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName);

            //Act 
            pagesPage.PagesSelectList.Select(pageName);
            ConfirmDialogHandler dialog = new ConfirmDialogHandler();
            using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
            {
                pagesPage.DeleteSelectedPageImage.ClickNoWait();
                dialog.WaitUntilExists();
                dialog.OKButton.Click();
            }
            System.Threading.Thread.Sleep(3000);
            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsFalse(pagesPage.PagesSelectList.Option(pageName).Exists);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
            ieInstance.GoTo(SiteURL + "/Admin/RecycleBin.aspx");
            RecycleBinPage recycleBin = new RecycleBinPage(homePage);
            Assert.IsTrue(recycleBin.PagesRecycleBin.InnerHtml.Contains(pageName));
        }


        [Test]
        [DependsOn("Delete_Page_From_Pages_Module")]
        public void Restore_Page()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Delete Page";
            RibbonBar ribbonBar = null;
            ControlPanel controlPanel = null;

            //Add a page to delete
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName);
            
            //Delete the page
            System.Threading.Thread.Sleep(1500);
            ieInstance.GoTo(SiteURL + "/DeletePage.aspx");
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.DeletePageLink.Click();
                homePage.YesConfirmationButton.Click();
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                ConfirmDialogHandler dialog = new ConfirmDialogHandler();
                using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
                {
                    controlPanel.DeletePageLink.ClickNoWait();
                    dialog.WaitUntilExists();
                    dialog.OKButton.Click();
                }
            }
            System.Threading.Thread.Sleep(1500);

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/RecycleBin.aspx");
            RecycleBinPage recycleBin = new RecycleBinPage(homePage);
            recycleBin.PagesRecycleBin.Select(pageName);
            recycleBin.RestorePageLink.Click();

            //Assert 
            System.Threading.Thread.Sleep(2000);
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsFalse(recycleBin.PagesRecycleBin.Option(pageName).Exists);
        }

        [Test]
        [DependsOn("Delete_Page_From_Pages_Module")]
        public void Delete_Page_From_Recycle_Bin()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            System.Threading.Thread.Sleep(1500);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Delete Page";

            //Add a page to delete
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName);
            System.Threading.Thread.Sleep(1500);

            //Delete the page
            ieInstance.GoTo(SiteURL + "/DeletePage.aspx");
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            if (!homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                controlPanel = new ControlPanel(homePage);
                ConfirmDialogHandler dialog1 = new ConfirmDialogHandler();
                using (new UseDialogOnce(ieInstance.DialogWatcher, dialog1))
                {
                    controlPanel.DeletePageLink.ClickNoWait();
                    dialog1.WaitUntilExists();
                    dialog1.OKButton.Click();
                }
            }
            else
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.DeletePageLink.Click();
                homePage.YesConfirmationButton.Click();
            }

            //Act 
            System.Threading.Thread.Sleep(1500);
            ieInstance.GoTo(SiteURL + "/Admin/RecycleBin.aspx");
            RecycleBinPage recycleBin = new RecycleBinPage(homePage);
            recycleBin.PagesRecycleBin.Select(pageName);
            recycleBin.DeletePageLink.ClickNoWait();
            homePage.YesConfirmationButton.Click();

            //Assert 
            System.Threading.Thread.Sleep(2000);
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsFalse(recycleBin.PagesRecycleBin.Option(pageName).Exists);
        }


        [Test]
        [DependsOn("Delete_Page_From_Pages_Module")]
        public void Empty_Recycle_Bin()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Delete Page";
            String pageName2 = "test page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;

            //Add a page to delete
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName);

            //Add another page 
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            pagesPage.AddPage(pageName2);

            //Add a module to the page and delete it 
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            System.Threading.Thread.Sleep(1500);
            if (!homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                controlPanel = new ControlPanel(homePage);
                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddModuleToPage("Delete Module", "HTML");
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddModuleToPage("Delete Module", "HTML Pro");
                }
            }
            else
            {
                usesRibbonBar = true;
                ribbonBar = new RibbonBar(homePage);
                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPage("Delete Module", "HTML");
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPage("Delete Module", "HTML Pro");

                }
            }
            System.Threading.Thread.Sleep(1500);
            ModulePage modulePage = new ModulePage(homePage);
           // modulePage.ModuleActionMenuImage.FireEvent("onmouseover");
            ConfirmDialogHandler dialog = new ConfirmDialogHandler();
            using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
            {
                modulePage.DeleteModuleImage.ClickNoWait();
                dialog.WaitUntilExists();
                dialog.OKButton.Click();
            }
            System.Threading.Thread.Sleep(1000);
            //modulePage.ModuleActionMenuImage.FireEvent("onmouseover");
            dialog = new ConfirmDialogHandler();
            using (new UseDialogOnce(ieInstance.DialogWatcher, dialog))
            {
                modulePage.DeleteModuleImage.ClickNoWait();
                dialog.WaitUntilExists();
                dialog.OKButton.Click();
            }

            //Delete the page
            ieInstance.GoTo(SiteURL + "/DeletePage.aspx");
            System.Threading.Thread.Sleep(1500);
            if (!usesRibbonBar)
            {
                ConfirmDialogHandler dialog1 = new ConfirmDialogHandler();
                using (new UseDialogOnce(ieInstance.DialogWatcher, dialog1))
                {
                    controlPanel.DeletePageLink.ClickNoWait();
                    dialog1.WaitUntilExists();
                    dialog1.OKButton.Click();
                }
            }
            else
            {
                ribbonBar.DeletePageLink.Click();
                homePage.YesConfirmationButton.Click();
            }

            //Act 
            ieInstance.GoTo(SiteURL + "/Admin/RecycleBin.aspx");
            RecycleBinPage recycleBin = new RecycleBinPage(homePage);
            recycleBin.EmptyBinLink.ClickNoWait();
            homePage.YesConfirmationButton.Click();

            //Assert 
            System.Threading.Thread.Sleep(2000);
            Assert.IsFalse(recycleBin.ModulesRecycleBin.Option(pageName2 + " - Delete Module").Exists);
            Assert.IsFalse(recycleBin.ModulesRecycleBin.Option(pageName2 + " - Enter Title").Exists);
            Assert.IsFalse(recycleBin.PagesRecycleBin.Option(pageName).Exists);
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsFalse(menu.MainMenu.InnerHtml.Contains(pageName));
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            System.Threading.Thread.Sleep(2000);
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Delete Module"));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Enter Title"));
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Copy_Page_From_Control_Panel()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            String copyName = "Copy Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = !homePage.SiteIsUsingIconBar();

            //Add a page to the site
            PageSettingsPage newPage = new PageSettingsPage(homePage);


            if(usesRibbonBar)
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.AddPageLink.Click();
                newPage.AddPageSelectTemplate(pageName, "None Specified");
                System.Threading.Thread.Sleep(1500);

                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);

                }
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
                newPage.AddPageSelectTemplate(pageName, "None Specified");
                System.Threading.Thread.Sleep(1500);

                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML", "Unique Text", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Copy Module", "HTML Pro", "Unique Text", 0);
                }
            }

            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            ModulePage modulePage = new ModulePage(homePage);
            
            //Act 
            if (usesRibbonBar)
            {
                ribbonBar.CurrentPageTabLink.Click();
                ribbonBar.CopyPageLink.Click();
            }
            else
            {
                controlPanel.CopyPageLink.Click();
            }
            newPage.PageNameField.Value = copyName;
            newPage.CopyPageSelectList.Select(pageName);
            newPage.CopyRadioButton.Checked = true;
            newPage.AddPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(3000);

            //Assert
            ieInstance.GoTo(SiteURL + "/copypage.aspx");
            SiteMenu menu = new SiteMenu(homePage);
            Assert.AreEqual(copyName, menu.BreadCrumbSpan.Text);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(copyName));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
            //Change the text on the copied module
            modulePage.AddContentToModule("Something new", 0);
           

            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Copy Module"));
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
            Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Something new"));
            //Change the text on the original module
            modulePage.AddContentToModule("different text", 0);
            
            ieInstance.GoTo(SiteURL + "/copypage.aspx");
            Assert.IsTrue(homePage.ContentPane.InnerHtml.Contains("Something new"));
            Assert.IsFalse(homePage.ContentPane.InnerHtml.Contains("Unique Text"));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_From_Pages_Module_Move_Page_Up()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName1 = "Test Page 1";
            String pageName2 = "Test Page 2";
            String pageName3 = "Test Page 3";

            //Add pages to the site
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName1);
            pagesPage.AddPageAfter(pageName2, pageName1);
            pagesPage.AddPageAfter(pageName3, pageName2);

            //Act 
            pagesPage.PagesSelectList.Select(pageName3);
            pagesPage.MovePageUpButton.ClickNoWait();
            System.Threading.Thread.Sleep(1000);

            //Assert 
            int page1Index = pagesPage.PagesSelectList.Option(pageName1).Index;
            int page2Index = pagesPage.PagesSelectList.Option(pageName2).Index;
            int page3Index = pagesPage.PagesSelectList.Option(pageName3).Index;
            Assert.IsTrue(page2Index > page3Index);
            Assert.IsTrue(page3Index > page1Index);
            int offSetVal = page2Index - page3Index;
            Assert.IsTrue(offSetVal == 1);
            offSetVal = page3Index - page1Index;
            Assert.IsTrue(offSetVal == 1);
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_From_Pages_Module_Move_Page_Top()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName1 = "Test Page 1";
            String pageName2 = "Test Page 2";
            String pageName3 = "Test Page 3";

            //Add pages to the site
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName1);
            pagesPage.AddPageAfter(pageName2, pageName1);
            pagesPage.AddPageAfter(pageName3, pageName2);

            //Act 
            pagesPage.PagesSelectList.Select(pageName3);
            pagesPage.MovePageTopButton.ClickNoWait();
            System.Threading.Thread.Sleep(1000);

            //Assert 
            int page1Index = pagesPage.PagesSelectList.Option(pageName1).Index;
            int page2Index = pagesPage.PagesSelectList.Option(pageName2).Index;
            int page3Index = pagesPage.PagesSelectList.Option(pageName3).Index;
            int homeIndex = pagesPage.PagesSelectList.Option("Home").Index;
            Assert.IsTrue(homeIndex > page3Index);
            Assert.IsTrue(page1Index > page3Index);
            Assert.IsTrue(page2Index > page1Index);
            int offSetVal = page1Index - page3Index;
            Assert.IsTrue(offSetVal == 2);
            offSetVal = page2Index - page3Index;
            Assert.IsTrue(offSetVal == 3);
            offSetVal = homeIndex - page3Index;
            Assert.IsTrue(offSetVal == 1);
            Assert.IsTrue(page3Index == 0);
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_From_Pages_Module_Move_Page_Bottom()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName1 = "Test Page 1";
            String pageName2 = "Test Page 2";
            String pageName3 = "Test Page 3";

            //Add pages to the site
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName1);
            pagesPage.AddPageAfter(pageName2, pageName1);
            pagesPage.AddPageAfter(pageName3, pageName2);

            //Act 
            pagesPage.PagesSelectList.Select(pageName3);
            pagesPage.MovePageBottomButton.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert 
            int numPages = pagesPage.PagesSelectList.Options.Count;
            int page3Index = pagesPage.PagesSelectList.Option(pageName3).Index;
            Assert.IsTrue(page3Index == (numPages - 1));
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_From_Pages_Module_Move_Page_Down()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName1 = "Test Page 1";
            String pageName2 = "Test Page 2";
            String pageName3 = "Test Page 3";

            //Add pages to the site
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName1);
            pagesPage.AddPageAfter(pageName2, pageName1);
            pagesPage.AddPageAfter(pageName3, pageName2);

            //Act 
            pagesPage.PagesSelectList.Select(pageName1);
            pagesPage.MovePageDownButton.ClickNoWait();
            System.Threading.Thread.Sleep(1000);

            //Assert 
            int page1Index = pagesPage.PagesSelectList.Option(pageName1).Index;
            int page2Index = pagesPage.PagesSelectList.Option(pageName2).Index;
            int page3Index = pagesPage.PagesSelectList.Option(pageName3).Index;
            Assert.IsTrue(page1Index > page2Index);
            Assert.IsTrue(page3Index > page1Index);
            int offSetVal = page3Index - page1Index;
            Assert.IsTrue(offSetVal == 1);
            offSetVal = page1Index - page2Index;
            Assert.IsTrue(offSetVal == 1);
        }
        
        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_From_Pages_Module_Move_Page_Right()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            String child1 = "Child 1";
            String child2 = "Child 2";
            String grandChild = "Grandchild";

            //Add a page to the site
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName);
            

            //Add a child page for the site
            pagesPage.AddChildPage(child1, pageName);

            //Add a child page for the site
            pagesPage.AddChildPage(child2, pageName);

            //Add a grandchild page for the site
            pagesPage.AddChildPage(grandChild, "..." + child2);

            //Act 
            pagesPage.PagesSelectList.Select("..." + child2);
            pagesPage.MovePageRightButton.Click();
            System.Threading.Thread.Sleep(1000);

            //Assert 
            Assert.IsTrue(pagesPage.PagesSelectList.Option("......" + child2).Exists);
            Assert.IsTrue(pagesPage.PagesSelectList.Option("..." + child1).Exists);
            Assert.IsTrue(pagesPage.PagesSelectList.Option("........." + grandChild).Exists);
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
        }

        [Test]
        [DependsOn("Add_Page_From_Pages_Module")]
        public void Modify_From_Pages_Module_Move_Page_Left()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            String child1 = "Child 1";
            String child2 = "Child 2";
            String grandChild = "Grandchild";

            //Add a page to the site
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            pagesPage.AddPage(pageName);


            //Add a child page for the site
            pagesPage.AddChildPage(child1, pageName);

            //Add a child page for the site
            pagesPage.AddChildPage(child2, pageName);

            //Add a grandchild page for the site
            pagesPage.AddChildPage(grandChild, "..." + child2);

            //Act 
            pagesPage.PagesSelectList.Select("..." + child2);
            pagesPage.MovePageLeftButton.ClickNoWait();
            System.Threading.Thread.Sleep(1000);

            //Assert 
            Assert.IsTrue(pagesPage.PagesSelectList.Option(child2).Exists);
            Assert.IsTrue(pagesPage.PagesSelectList.Option("..." + child1).Exists);
            Assert.IsTrue(pagesPage.PagesSelectList.Option("..." + grandChild).Exists);
            Assert.IsTrue(pagesPage.PagesSelectList.Option(pageName).Exists);
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Export_Page_From_Control_Panel_Content_Excluded_Import_Create_New_View()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;

            //Add a page to the site
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplateAllUsersView(pageName, "None Specified");

            //Add content to the page 
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            System.Threading.Thread.Sleep(1500);
            if (!usesRibbonBar)
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Export Module", "HTML", "This is content for importing...", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Export Module", "HTML Pro", "This is content for importing...", 0);
                }
            }
            else
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Export Module", "HTML", "This is content for importing...", 0);

                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Export Module", "HTML Pro", "This is content for importing...", 0);

                }
            }
            System.Threading.Thread.Sleep(1500);

            //Act
            if (usesRibbonBar)
            {
                //ribbonBar.CurrentPageTabLink.Click();
                ribbonBar.ExportPageLink.Click();
            }
            else
            {
                controlPanel.ExportPageLink.Click();
            }
            ExportImportPage exportPage = new ExportImportPage(homePage);
            exportPage.ExportTemplateFolderSelectList.Select("Templates");
            exportPage.TemplateNameField.Value = "TestPageNoContent";
            exportPage.TemplateDescriptionField.Value = "This is a template of Test page for testing";
            exportPage.IncludeContentCheckbox.Checked = false;
            exportPage.ExportLink.Click();
            System.Threading.Thread.Sleep(1000);

            //Assert 
            Assert.IsTrue(exportPage.ExportMessageSpan.InnerHtml.Contains("The Page Template Has Been Created to"));
            Assert.IsTrue(File.Exists(PhysicalPath + @"\Portals\0\Templates\TestPageNoContent.page.template"));

            //Act (Import the template)
            if (usesRibbonBar)
            {
                //ribbonBar.CurrentPageTabLink.Click();
                ribbonBar.ImportPageLink.Click();
            }
            else
            {
                controlPanel.ImportPageLink.Click();
            }
            System.Threading.Thread.Sleep(1500);
            exportPage.ImportFolderSelectList.Select("Templates");
            exportPage.TemplateSelectList.Select("TestPageNoContent");
            System.Threading.Thread.Sleep(1000);
            exportPage.CreateNewPageRadioButton.Checked = true;
            exportPage.ViewImportedPageRadioButton.Checked = true;
            exportPage.ImportPageLink.ClickNoWait();
            System.Threading.Thread.Sleep(1500);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains("TestPageNoContent"));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains("TestPageNoContent"));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains("Export Module"));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("This is content for importing..."));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Visible By Administrators Only"));

            //Clean up the file
            File.Delete(PhysicalPath + @"\Portals\0\Templates\TestPageNoContent.page.template");
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Export_Page_From_Control_Panel_Content_Included_Import_Create_New_View()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            String pageName = "Test Page";
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;

            //Add a page to the site
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplateAllUsersView(pageName, "None Specified");

            //Add content to the page 
            ieInstance.GoTo(SiteURL + "/testpage.aspx");
            if (!usesRibbonBar)
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Export Module", "HTML", "This is content for importing...", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Export Module", "HTML Pro", "This is content for importing...", 0);
                }
            }
            else
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Export Module", "HTML", "This is content for importing...", 0);

                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Export Module", "HTML Pro", "This is content for importing...", 0);

                }
            }

            //Act 
            if (usesRibbonBar)
            {
                //ribbonBar.CurrentPageTabLink.ClickNoWait();
                ribbonBar.ExportPageLink.Click();
            }
            else
            {
                controlPanel.ExportPageLink.Click();
            }
            System.Threading.Thread.Sleep(1500);
            ExportImportPage exportPage = new ExportImportPage(homePage);
            exportPage.ExportTemplateFolderSelectList.Select("Templates");
            exportPage.TemplateNameField.Value = "TestPageNoContent";
            exportPage.TemplateDescriptionField.Value = "This is a template of Test page for testing";
            exportPage.IncludeContentCheckbox.Checked = true;
            exportPage.ExportLink.Click();
            System.Threading.Thread.Sleep(1000);

            //Assert 
            Assert.IsTrue(exportPage.ExportMessageSpan.InnerHtml.Contains("The Page Template Has Been Created to"));
            Assert.IsTrue(File.Exists(PhysicalPath + @"\Portals\0\Templates\TestPageNoContent.page.template"));

            //Act (Import the template)
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            if (usesRibbonBar)
            {
                //ribbonBar.CurrentPageTabLink.Click();
                ribbonBar.ImportPageLink.Click();
            }
            else
            {
                controlPanel.ImportPageLink.Click();
            }
            System.Threading.Thread.Sleep(1500);
            exportPage.ImportFolderSelectList.Select("Templates");
            exportPage.TemplateSelectList.Select("TestPageNoContent");
            System.Threading.Thread.Sleep(1000);
            exportPage.CreateNewPageRadioButton.Checked = true;
            exportPage.ViewImportedPageRadioButton.Checked = true;
            exportPage.ImportPageLink.Click();

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains("TestPageNoContent"));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains("TestPageNoContent"));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains("Export Module"));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains("This is content for importing..."));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Visible By Administrators Only"));

            //Clean up the file
            File.Delete(PhysicalPath + @"\Portals\0\Templates\TestPageNoContent.page.template");
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        [DependsOn("Export_Page_From_Control_Panel_Content_Included_Import_Create_New_View")]
        public void Import_Page_From_Control_Panel_Replace_And_View()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;
            String pageName = "Test Page";
            String replacePage = "Replace Page";
            String templateName = "TestPageWContent";
            String pageContent = "This is module content for template testing...";
            
            //Export a page
            ExportImportPage exportPage = new ExportImportPage(homePage);
            exportPage.CreateAndExportPage(pageName, pageContent, templateName, true, homePage, VersionType, SiteURL);
            ieInstance.GoTo(SiteURL + "/Home.aspx");

            //Create a page to replace 
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(replacePage, "None Specified");

            //Add content to the page 
            ieInstance.GoTo(SiteURL + "/replacepage.aspx");
            System.Threading.Thread.Sleep(1000);
            if (!usesRibbonBar)
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Replace Module", "HTML", "This will be replaced!", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Replace Module", "HTML Pro", "This will be replaced!", 0);
                }
            }
            else
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Replace Module", "HTML", "This will be replaced!", 0);

                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Replace Module", "HTML Pro", "This will be replaced!", 0);

                }
            }


            //Act 
            if (usesRibbonBar)
            {
                ribbonBar.ImportPageLink.Click();
            }
            else
            {
                controlPanel.ImportPageLink.Click();
            }
            exportPage.ImportFolderSelectList.Select("Templates");
            exportPage.TemplateSelectList.Select(templateName);
            System.Threading.Thread.Sleep(1000);
            exportPage.ReplaceCurrentPageRadioButton.Checked = true;
            System.Threading.Thread.Sleep(1000);
            exportPage.ViewImportedPageRadioButton.Checked = true;
            exportPage.ImportPageLink.Click();
            System.Threading.Thread.Sleep(1000);

            //Assert
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(replacePage));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(replacePage));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains("Export Module"));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Replace Module"));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains(pageContent));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Visible By Administrators Only"));

            //Clean up the file
            File.Delete(PhysicalPath + @"\Portals\0\Templates\" + templateName +".page.template");
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        [DependsOn("Export_Page_From_Control_Panel_Content_Included_Import_Create_New_View")]
        public void Import_Page_From_Control_Panel_Replace_And_Edit()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;
            String pageName = "Test Page";
            String replacePage = "Replace Page";
            String templateName = "TestPageWContent";
            String pageContent = "This is module content for template testing...";

            //Export a page
            ExportImportPage exportPage = new ExportImportPage(homePage);
            exportPage.CreateAndExportPage(pageName, pageContent, templateName, true, homePage, VersionType, SiteURL);
            ieInstance.GoTo(SiteURL + "/Home.aspx");

            //Create a page to replace 
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(replacePage, "None Specified");

            //Add content to the page 
            ieInstance.GoTo(SiteURL + "/replacepage.aspx");
            if (!usesRibbonBar)
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Replace Module", "HTML", "This will be replaced!", 0);
                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    controlPanel.AddHTMLModuleToPageWithContent("Replace Module", "HTML Pro", "This will be replaced!", 0);
                }
            }
            else
            {
                if (VersionType.CompareTo("Community") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Replace Module", "HTML", "This will be replaced!", 0);

                }
                else if (VersionType.CompareTo("Professional") == 0 || VersionType.CompareTo("Enterprise") == 0)
                {
                    ribbonBar.AddHTMLModuleToPageWithContent("Replace Module", "HTML Pro", "This will be replaced!", 0);

                }
            }


            //Act 
            if (usesRibbonBar)
            {
                ribbonBar.ImportPageLink.Click();
            }
            else
            {
                controlPanel.ImportPageLink.Click();
            }
            exportPage.ImportFolderSelectList.Select("Templates");
            exportPage.TemplateSelectList.Select(templateName);
            System.Threading.Thread.Sleep(1000);
            exportPage.ReplaceCurrentPageRadioButton.Checked = true;
            System.Threading.Thread.Sleep(1000);
            exportPage.EditImportedPageRadioButton.Checked = true;
            exportPage.ImportPageLink.Click();
            System.Threading.Thread.Sleep(1000);

            //Assert
            Assert.IsTrue(homePage.ModuleTitleSpans.Count == 1);
            Assert.IsTrue(homePage.ModuleTitleSpan.InnerHtml.Contains("Page Settings"));
            ieInstance.GoTo(SiteURL + "/replacepage.aspx");
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(replacePage));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(replacePage));
            Assert.IsTrue(menu.MainMenu.InnerHtml.Contains(pageName));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains("Export Module"));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Replace Module"));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains(pageContent));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Visible By Administrators Only"));

            //Clean up the file
            File.Delete(PhysicalPath + @"\Portals\0\Templates\" + templateName + ".page.template");
        }


        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        [DependsOn("Export_Page_From_Control_Panel_Content_Included_Import_Create_New_View")]
        public void Import_Page_From_Control_Panel_Insert_Before()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;
            String pageName = "Test Page";
            String secondPage = "Second Page";
            String templateName = "TestPageWContent";
            String pageContent = "This is module content for template testing...";

            //Export a page
            ExportImportPage exportPage = new ExportImportPage(homePage);
            exportPage.CreateAndExportPage(pageName, pageContent, templateName, true, homePage, VersionType, SiteURL);
            ieInstance.GoTo(SiteURL + "/Home.aspx");

            //Create a page 
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(secondPage, "None Specified");

            //Act 
            if (usesRibbonBar)
            {
                ribbonBar.ImportPageLink.Click();
            }
            else
            {
                controlPanel.ImportPageLink.Click();
            }
            exportPage.ImportFolderSelectList.Select("Templates");
            exportPage.TemplateSelectList.Select(templateName);
            System.Threading.Thread.Sleep(3000);
            exportPage.InsertBeforeRadioButton.Checked = true;
            System.Threading.Thread.Sleep(1000);
            exportPage.InsertPageSelectList.Select(secondPage);
            exportPage.ViewImportedPageRadioButton.Checked = true;
            exportPage.ImportPageLink.Click();
            System.Threading.Thread.Sleep(1000);

            //Assert
            //Check the new page was created correctly
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(templateName));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains("Export Module"));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains(pageContent));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Visible By Administrators Only"));

            //Check the position of the page is correct
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            int templatePageIndex = pagesPage.GetPageIndex(templateName);
            int otherPageIndex = pagesPage.GetPageIndex(secondPage);
            Assert.IsTrue(otherPageIndex > templatePageIndex);
            int offSetVal = otherPageIndex - templatePageIndex;
            Assert.IsTrue(offSetVal == 1);

            //Clean up the file
            File.Delete(PhysicalPath + @"\Portals\0\Templates\" + templateName + ".page.template");
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        [DependsOn("Export_Page_From_Control_Panel_Content_Included_Import_Create_New_View")]
        public void Import_Page_From_Control_Panel_Insert_After()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;
            String pageName = "Test Page";
            String secondPage = "Second Page";
            String templateName = "TestPageWContent";
            String pageContent = "This is module content for template testing...";

            //Export a page
            ExportImportPage exportPage = new ExportImportPage(homePage);
            exportPage.CreateAndExportPage(pageName, pageContent, templateName, true, homePage, VersionType, SiteURL);
            ieInstance.GoTo(SiteURL + "/Home.aspx");

            //Create a page 
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPageSelectTemplate(secondPage, "None Specified");

            //Act 
            if (usesRibbonBar)
            {
                //ribbonBar.CurrentPageTabLink.Click();
                ribbonBar.ImportPageLink.Click();
            }
            else
            {
                controlPanel.ImportPageLink.Click();
            }
            exportPage.ImportFolderSelectList.Select("Templates");
            exportPage.TemplateSelectList.Select(templateName);
            System.Threading.Thread.Sleep(3000);
            exportPage.InsertAfterRadioButton.Checked = true;
            System.Threading.Thread.Sleep(1000);
            exportPage.InsertPageSelectList.Select(secondPage);
            exportPage.ViewImportedPageRadioButton.Checked = true;
            exportPage.ImportPageLink.Click();
            System.Threading.Thread.Sleep(1000);

            //Assert
            //Check the new page was created correctly
            SiteMenu menu = new SiteMenu(homePage);
            Assert.IsTrue(menu.BreadCrumbSpan.Text.Contains(templateName));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains("Export Module"));
            Assert.IsTrue(homePage.ContentDiv.InnerHtml.Contains(pageContent));
            Assert.IsFalse(homePage.ContentDiv.InnerHtml.Contains("Visible By Administrators Only"));

            //Check the position of the page is correct
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            int templatePageIndex = pagesPage.GetPageIndex(templateName);
            int otherPageIndex = pagesPage.GetPageIndex(secondPage);
            Assert.IsTrue(otherPageIndex < templatePageIndex);
            int offSetVal = templatePageIndex - otherPageIndex;
            Assert.IsTrue(offSetVal == 1);
            

            //Clean up the file
            File.Delete(PhysicalPath + @"\Portals\0\Templates\" + templateName + ".page.template");
        }

        [Test]
        [DependsOn("Add_Page_From_Control_Panel_Ribbon_Bar")]
        public void Add_Duplicate_Page_Fail()
        {
            //Arrange
            WatiNBase homePage = new WatiNBase(ieInstance, SiteURL, DatabaseName);
            LoginPage loginPage = new LoginPage(homePage);
            loginPage.LoginUser(TestUsers.Admin.UserName, TestUsers.Admin.Password);
            ControlPanel controlPanel = null;
            RibbonBar ribbonBar = null;
            bool usesRibbonBar = false;
            String pageName = "Test Page";

            //Create a page 
            if (homePage.ControlPanelElement.Id.Contains(homePage.RibbonBarID))
            {
                ribbonBar = new RibbonBar(homePage);
                ribbonBar.NewPageLink.Click();
                usesRibbonBar = true;
            }
            else
            {
                controlPanel = new ControlPanel(homePage);
                controlPanel.AddPageLink.Click();
            }
            PageSettingsPage newPage = new PageSettingsPage(homePage);
            newPage.AddPage(pageName);

            //Act 
            ieInstance.GoTo(SiteURL + "/Home.aspx");
            if (usesRibbonBar)
            {
                ribbonBar.NewPageLink.Click();
            }
            else
            {
                controlPanel.AddPageLink.Click();
            }
            newPage.AddPage(pageName);

            //Assert
            Assert.IsTrue(homePage.PopUpMessageSpan.InnerHtml.Contains("The Page Name you chose is already being used for another page at the same level of the page heirarchy."));
            ieInstance.GoTo(SiteURL + "/Admin/Pages.aspx");
            AdminPagesPage pagesPage = new AdminPagesPage(homePage);
            Assert.IsTrue(pagesPage.PagesPanel.Spans.Filter(Find.ByText(s => s.Contains(pageName))).Count == 1);
        }


        #endregion
    }
}

